package org.test;

import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.VerticalLayout;

public class ImmediatelyRichTextArea extends VerticalLayout {
	public ImmediatelyRichTextArea() {
		RichTextArea textArea = new RichTextArea();
		textArea.setImmediate(true);

		final Button saveButton = new Button("Saved");
		saveButton.setEnabled(false);

		textArea.addValueChangeListener(new ValueChangeListener() {

			@Override
			public void valueChange(ValueChangeEvent event) {
				saveButton.setCaption("Save");
				saveButton.setEnabled(true);
			}

		});

		saveButton.addClickListener(new ClickListener() {
			@Override
			public void buttonClick(ClickEvent event) {
				saveButton.setCaption("Saved");
				saveButton.setEnabled(false);
			}
		});

		this.addComponent(textArea);
		this.addComponent(saveButton);
	}
}
